package com.atguigu.spzx.service.user.service.impl;

import com.atguigu.spzx.service.user.mapper.RegionMapper;
import com.atguigu.spzx.service.user.service.RegionService;
import com.atguigu.spzx.model.entity.region.Region;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * title:
 * author: zgl
 * date: 2024/1/18
 * description：
 */
@Service
public class RegionServiceImpl extends ServiceImpl<RegionMapper, Region> implements RegionService {
    @Override
    public List<Region> findByParentCode(String parentCode) {
        List<Region> list = this.list(Wrappers.lambdaQuery(Region.class).eq(Region::getParentCode, parentCode));
        return list;
    }


    @Override
    public Region findByCode(String code) {
        Region regionName = this.getOne(Wrappers.lambdaQuery(Region.class).eq(Region::getCode, code).select(Region::getName));
        return regionName;
    }
}
